﻿@{
    Layout = "Admin_Layout";
}
@section Style {
    <style>
        .el-button-danger {
            height: 29px;
            line-height: 0.4;
            width: 80px;
            border: 1px solid #f57d7d;
            border-radius: 2px;
        }

            .el-button-danger span {
                font-family: Microsoft YaHei UI;
                color: #fff;
                font-size: 14px;
                letter-spacing: 1px;
            }

        .el-button-danger-clear {
            height: 29px;
            line-height: 0.4;
            width: 100px;
            border: 1px solid #f57d7d;
            border-radius: 2px;
        }

            .el-button-danger-clear span {
                font-family: Microsoft YaHei UI;
                color: #fff;
                font-size: 14px;
                letter-spacing: 1px;
            }

        /* 搜索框 */
        .input-with-select {
            width: 220px;
            padding: 4px;
        }

        /* 下拉框 */
        .my-el-select {
            width: 120px;
            padding: 4px;
            margin-right: 15px;
        }

            /* selecte 框的高度设置，默认是 40px*/
            .my-el-select .el-input__inner {
                height: 28px;
            }
            /* 下面设置右侧按钮居中 */
            .my-el-select .el-input__suffix {
                top: 4px;
            }

            .my-el-select .el-input__icon {
                line-height: inherit;
            }

            .my-el-select .el-input__suffix-inner {
                display: inline-block;
            }
    </style>
}
<div class="mydiv">
    <div style="float:left;">
        <div style="margin-left:20px;">
            <el-row style="display:flex;" :gutter="15">
                <el-col :span="3" style="justify-content:right;align-items:center;display:flex;"><span style="color:red;font-size:13px;margin-right:4px;">*</span>标题</el-col>
                <el-col :span="21">
                    <el-input maxlength="30" v-model.trim="title"></el-input>
                </el-col>
            </el-row>
            <el-row style="margin-top:8px;" :gutter="15">
                <el-col :span="3" style="justify-content:right;display:flex;"><span style="color:red;font-size:13px;margin-right:4px;">*</span>摘要</el-col>
                <el-col :span="21">
                    <el-input maxlength="50" v-model.trim="subTitle" type="textarea" resize="none" :autosize="{ minRows: 2,maxRows:2}"></el-input>
                </el-col>
            </el-row>
            <el-row style="margin-top:8px;" :gutter="15">
                <el-col :span="3" style="justify-content:right;display:flex;"><span style="color:red;font-size:13px;margin-right:4px;">*</span>内容</el-col>
                <el-col :span="21">
                    <script id="editor" type="text/plain" style="width:504px;height:200px;"></script>
                </el-col>
            </el-row>
            <el-row style="margin-top:8px;display:flex;" :gutter="15">
                <el-col :span="3" style="justify-content:right;align-items:center;display:flex;"><span style="color:red;font-size:13px;margin-right:4px;">*</span><span>分类</span></el-col>
                <el-col :span="8">
                        <el-select v-model="selectedSpeciesItem" placeholder="请选择分类">
                            <el-option v-for="item in speciesItems" :label="item.name" :value="item.id"></el-option>
                        </el-select>
                </el-col>
            </el-row>
            <el-row style="margin-top:8px;display:flex;" :gutter="15">
                <el-col :span="3" style="justify-content:right;display:flex;"><span>推荐</span></el-col>
                <el-col :span="8">
                    <el-radio-group v-model="isRecommend">
                        <el-radio :label="1">不推荐</el-radio>
                        <el-radio :label="2">推荐</el-radio>
                    </el-radio-group>
                </el-col>
            </el-row>
        </div>
        <div style="margin-top:20px;">
            <div style="float:left;margin-left:20px;width:256px;">
                <div><img style="width:256px;height:160px;" :src="coverImgUrl" title="请选择图片" /></div>
                <div>
                    <el-upload class="upload"
                               list-type="picture"
                               accept=".jpg , .jpeg , .png"
                               :show-file-list="false"
                               ref="upload"
                               action="string"
                               :file-list="coverImgList"
                               :auto-upload="false"
                               :http-request="uploadFile"
                               :on-change="coverHandleChange"
                               :on-preview="handlePreview"
                               :on-remove="handleRemove"
                               multiple="false">
                        <el-button slot="trigger" size="small" type="primary" @@click="coverImgFile">封面图片</el-button>
                        <div slot="tip" class="el-upload__tip"><span style="color:red;font-size:13px;margin-right:4px;">*</span>[jpg/jpeg/png图片，小于{{imgSize}}K]</div>
                    </el-upload>
                </div>
            </div>
            <div style="float:left;margin-left:20px;">
                <div>
                    <video width="300" height="160" controls :src="videoUrl" style="background-color:silver;">
                        <source type="video/mp4">
                        <source type="video/avi">
                        <source type="video/webm">
                        您的浏览器不支持 video 属性。
                    </video>
                </div>
                <div>
                    <el-upload class="upload"
                               accept=".mp4 , .webm"
                               :show-file-list="false"
                               action="string"
                               :file-list="videoList"
                               :auto-upload="false"
                               :on-change="videoHandleChange"
                               multiple="false">
                        <el-button slot="trigger" size="small" type="primary" @@click="videoFile">宠物视频</el-button>
                        <div slot="tip" class="el-upload__tip">[mp4/avi/webm视频，小于{{videoSize}}M]</div>
                    </el-upload>
                </div>
            </div>
        </div>
        <div style="clear:both;"></div>
        <div style="margin-left:20px;margin-top:20px;">
            <div>
                <div style="float:left;"><img style="width:185px;height:160px;" :src="otherImgUrl1" title="请选择图片" /></div>
                <div style="float:left;margin-left:10px;"><img style="width:185px;height:160px;" :src="otherImgUrl2" title="请选择图片" /></div>
                <div style="float:left;margin-left:10px;"><img style="width:185px;height:160px;" :src="otherImgUrl3" title="请选择图片" /></div>
            </div>
            <div style="clear:both;"></div>
            <div>
                <el-upload class="upload"
                           :limit="3"
                           :on-exceed="otherHandleExceed"
                           accept=".jpg , jpeg , .png"
                           :show-file-list="false"
                           list-type="picture"
                           ref="upload"
                           action="string"
                           :auto-upload="false"
                           :file-list="otherImgList"
                           :on-change="otherHandleChange"
                           multiple="true">
                    <el-button slot="trigger" size="small" type="primary" @@click="otherImgFile">其他图片</el-button>
                    <div slot="tip" class="el-upload__tip">[jpg/jpeg/png图片，每张小于{{imgSize}}K]</div>
                </el-upload>
            </div>
        </div>
        <div style="background-color:black;height:1px; border:none;margin-top:15px;"></div>
        <div style="margin-bottom:15px;margin-top:15px;display:none;" id="progressDiv">
            <el-row style="margin-top:8px;display:flex;" :gutter="15">
                <el-col :span="4" style="text-align:right;margin-left:20px;font-size:15px;">
                    提交进度
                </el-col>
                <el-col :span="18">
                    <el-progress :text-inside="true" :stroke-width="20" :percentage="percentage"></el-progress>
                </el-col>
            </el-row>
        </div>
        <div style="margin-left:20px;width:580px;margin-top:15px;margin-bottom:10px;">
            <el-button type="primary" :disabled="submitBtnDisabled" @@click="submitForm" style="width:110px;">确 定</el-button>
            <el-button @@click="clearForm" style="width:110px;">清 空</el-button>
        </div>
    </div>
    <div style="background-color:silver;float:left;margin-left:30px;height:400px;width:1px;"></div>
    <div style="float:left;margin-left:30px;max-width:900px;">
        <div style="height:40px;">
            <div style="float:left;padding:4px;"><el-button type="danger" class="el-button-danger" @@click="handleBatchDelete">删除</el-button></div>
            <div style="float:left;padding:4px;"><el-button type="danger" class="el-button-danger-clear" @@click="handleClearRecom">清除推荐</el-button></div>
            <div style="text-align: right;">
                <div style="float:right;">
                    <div style="float:right;">
                        <el-input placeholder="请输入标题或摘要搜索" v-model.trim="searchInput" class="input-with-select" size="mini">
                            <el-button slot="append" icon="el-icon-search" @@click="searchHandle"></el-button>
                        </el-input>
                    </div>
                    <el-select placeholder="请选择分类" v-model="searchSpeciesItem" @@change="searchSpeciesChanged" class="my-el-select">
                        <el-option v-for="item in speciesItemsForSearch" :label="item.name" :value="item.id"></el-option>
                    </el-select>
                </div>
            </div>
        </div>
        <div>
            <template>
                <el-table :data="tableData" :row-style="{height: '48px'}" :cell-style="{padding: '0'}"
                          style="width: 100%;border-top:1px solid;border-color:lightgray;font-size:13px;"
                          max-height="800px" @@selection-change="handleSelectionChange">
                    <el-table-column type="selection" width="50" fixed>
                    </el-table-column>
                    <el-table-column prop="date"
                                     label="日期"
                                     width="140">
                    </el-table-column>
                    <el-table-column prop="title"
                                     label="标题"
                                     width="150">
                    </el-table-column>
                    <el-table-column prop="subtitle"
                                     label="摘要"
                                     width="150">
                    </el-table-column>
                    <el-table-column prop="species"
                                     label="分类"
                                     width="60">
                    </el-table-column>
                    <el-table-column prop="isrecommended"
                                     label="是否推荐"
                                     width="80">
                        <template slot-scope="scope">
                            <el-switch v-model="scope.row.isrecommended"
                                       @@change="isRecomChanged(scope.row)"
                                       active-text=""
                                       inactive-text="">
                            </el-switch>
                        </template>
                    </el-table-column>
                    <el-table-column fixed="right"
                                     label="操作"
                                     width="160">
                        <template slot-scope="scope">
                            <el-button size="mini"
                                       @@click="handleEdit(scope.$index, scope.row)">编辑</el-button>
                            <el-button size="mini"
                                       type="danger"
                                       @@click="handleDelete(scope.$index, scope.row)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </template>
        </div>
        <div style="">
            <div class="block" style="margin-top:18px;margin-bottom:20px;">
                <el-pagination @@size-change="handleSizeChange"
                               @@current-change="handleCurrentChange"
                               :current-page.sync="currentPageNum"
                               :page-size="pageSize"
                               layout="total, prev, pager, next, jumper"
                               background
                               :total="petInfoCount">
                </el-pagination>
            </div>
        </div>
    </div>
</div>
@section Scripts {
    <script type="text/javascript" charset="gbk" src="/ueditor/ueditor.config.js?v3"></script>
    <script type="text/javascript" charset="gbk" src="/ueditor/ueditor.all.js?v3"></script>
    <script type="text/javascript" charset="gbk" src="/ueditor/ueditor.parse.js?v3"></script>
    <script type="text/javascript" charset="gbk" src="/ueditor/lang/zh-cn/zh-cn.js?v3"></script>
    <script>
        var ue = UE.getEditor('editor');

        var app = new Vue({
            el: "#app",
            mounted: async function () {
                let that = this;//将vue对象的引用保存在that中

                that.speciesItemsForSearch.unshift({ "id": "0", "name": "全部" });
                that.getPetStory(1, '', 0, that.dataType);//获取宠物故事或养宠知识
                $("#app").show();//vue渲染完后显示界面
            },
            methods: {
                //是否推荐状态改变
                isRecomChanged(row) {
                    this.$confirm('确定要更改此条数据的推荐状态吗?', "确认",
                        {
                            confirmButtonText: "确定",
                            cancelButtonText: "取消",
                            type: "warning",
                        })
                        .then(async () => {

                            //调用后台接口
                            axios.post('../../Super/SuperHome/ChangeRecommendStatus', {
                                "dataid": row.dataid,
                                "isRecom": row.isrecommended,
                                "dataType": this.dataType
                            }).then(response => {
                                if (response.data === 'ok') {
                                    this.getPetStory(this.currentPageNum, this.searchInput, this.searchSpeciesItem, this.dataType);
                                    this.$message({
                                        type: 'success',
                                        message: '操作成功!'
                                    });
                                }
                            }, error => {
                                alert("错误提示：" + error.message);
                            });

                        })
                        .then(() => {
                            this.msgSuccess(text + "成功");
                        })
                        .catch(() => {
                            //取消
                            row.isrecommended = row.isrecommended === true ? false : true;
                        });
                },
                //改变种类搜索
                searchSpeciesChanged(value) {
                    this.searchSpeciesItem = value;
                    this.searchInput = '';
                    this.currentPageNum = 1;

                    this.getPetStory(this.currentPageNum, this.searchInput, this.searchSpeciesItem,this.dataType);
                },
                //搜索
                searchHandle() {
                    if (app.searchInput === '') {
                        this.$message.warning('请输入名称或品种搜索');
                        return;
                    }

                    if (app.searchInput.length > 20) {
                        this.$message.warning('搜索内容不能超过20个字符');
                        return;
                    }

                    this.currentPageNum = 1;
                    this.getPetStory(this.currentPageNum, app.searchInput, this.searchSpeciesItem,this.dataType);//获取宠物信息
                },
                //翻页
                handleCurrentChange(val) {
                    this.getPetStory(val, this.searchInput, this.searchSpeciesItem,this.dataType);
                },
                //清除推荐
                handleClearRecom(){
                    this.$confirm('此操作将会把所有推荐数据改为不推荐, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {

                        axios.post('../../Super/SuperHome/ClearRecommend', {
                            "dataid": -1,
                            "isRecom": false,
                            "dataType": this.dataType
                        }).then(response => {
                            if (response.data === 'ok') {
                                this.getPetStory(this.currentPageNum, this.searchInput, this.searchSpeciesItem, this.dataType);
                                this.$message({
                                    type: 'success',
                                    message: '操作成功!'
                                });
                            }
                        }, error => {
                            alert("错误提示：" + error.message);
                        });

                    }).catch(() => {
                    });
                },
                //批量删除
                handleBatchDelete() {
                    if (this.multipleSelection.length === 0) {
                        this.$message.warning('请选择数据');
                        return;
                    }

                    let ids = '';
                    this.multipleSelection.forEach((item) => {
                        ids += item.dataid + '|';
                    });

                    ids = ids.substring(0, ids.length - 1);

                    this.$confirm('此操作将永久删除宠物信息数据, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {

                        axios.post('../../Super/SuperHome/DeletePetStoryOrKnowledge', {
                            "dataids": ids,
                            "dataType":this.dataType
                        }).then(response => {
                            if (response.data === 'ok') {
                                this.getPetStory(this.currentPageNum, this.searchInput, this.searchSpeciesItem,this.dataType);
                                this.$message({
                                    type: 'success',
                                    message: '删除成功!'
                                });
                            }
                        }, error => {
                            alert("错误提示：" + error.message);
                        });

                    }).catch(() => {
                    });
                },
                //获取分页信息
                getPetStory(pageNum, searchInput, currentSpecialsNum, dataType) {
                    axios.post('../../Super/SuperHome/GetPaginationInfo', {
                        "pageNum": pageNum,
                        "titleOrSubTitle": searchInput,
                        "specialsNum": currentSpecialsNum,
                        "dataType": dataType
                    }).then(response => {
                        this.tableData = response.data.data;
                        this.petInfoCount = response.data.dataCount;

                        this.currentPageNum = pageNum;
                    }, error => {
                        alert("错误提示：" + error.message);
                    });
                },
                //编辑数据
                handleEdit(index, row) {
                    axios.post('../../Super/SuperHome/GetPetStoryOrKnowledgeByID', {
                        "dataid": row.dataid,
                        "dataType": this.dataType,
                    }).then(async response => {
                        await app.restorePetInfo(response.data);
                    }, error => {
                        alert("错误提示：" + error.message);
                    });
                },
                //单行删除
                handleDelete(index, row) {
                    this.$confirm('此操作将永久删除宠物信息数据, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        axios.post('../../Super/SuperHome/DeletePetStoryOrKnowledge', {
                            "dataids": row.dataid,
                            "dataType": this.dataType
                        }).then(response => {
                            if (response.data === 'ok') {
                                this.getPetStory(this.currentPageNum, this.searchInput, this.searchSpeciesItem,this.dataType);//获取宠物信息
                                this.$message({
                                    type: 'success',
                                    message: '删除成功!'
                                });
                            }
                        }, error => {
                            alert("错误提示：" + error.message);
                        });

                    }).catch(() => {
                        // this.$message({
                        //     type: 'info',
                        //     message: '已取消删除'
                        // });
                    });
                },
                handleSelectionChange(val) {
                    this.multipleSelection = val;
                },
                //编辑时恢复数据
                async restorePetInfo(data) {
                    this.dataid = data.id;
                    this.title = data.title;
                    this.subTitle = data.subtitle;
                    ue.setContent(data.content, false);
                    this.selectedSpeciesItem = data.speciesid;
                    this.isRecommend = data.isrecommended === true ? 2 : 1;

                    let URL = window.URL || window.webkitURL;

                    //封面
                    var vueFileObj = await app.getVueFile("../../Super/SuperHome/DownFile", data.coverimgsrc);
                    app.coverImgList = [];
                    app.coverImgList.push(vueFileObj);
                    app.coverImgUrl = URL.createObjectURL(vueFileObj.raw);

                    this.videoUrl = '';
                    this.videoList = [];
                    if (data.videosrc !== '' && data.videosrc !== null) {
                        this.videoUrl = "/file/super/videos/" + data.videosrc;
                    }

                    //视频
                    // if (data.videosrc !== '' && data.videosrc !== null) {
                    //     var vueFileObj = await app.getVueFile("../../Super/SuperHome/DownFile", data.videosrc);
                    //     app.videoList = [];
                    //     app.videoList.push(vueFileObj);
                    //     app.videoUrl = URL.createObjectURL(vueFileObj.raw);
                    // }

                    app.otherImgList = [];
                    app.otherImgUrl1 = '/img.jpg';
                    app.otherImgUrl2 = '/img.jpg';
                    app.otherImgUrl3 = '/img.jpg';
                    if (data.otherimgsrc !== '' && data.otherimgsrc !== null) {
                        let imgUrls = data.otherimgsrc.split('|');
                        for (var i = 0; i < imgUrls.length; i++) {
                            var imgurl = imgUrls[i];

                            var vueFileObj = await app.getVueFile("../../Super/SuperHome/DownFile", imgurl);
                            app.otherImgList.push(vueFileObj);

                            if (i === 0)
                                app.otherImgUrl1 = URL.createObjectURL(vueFileObj.raw);
                            else if (i === 1)
                                app.otherImgUrl2 = URL.createObjectURL(vueFileObj.raw);
                            else if (i === 2)
                                app.otherImgUrl3 = URL.createObjectURL(vueFileObj.raw);
                        }
                    }
                },
                coverImgFile() { },
                videoFile() { },
                otherImgFile() {
                    if (app.otherImgList.length < 3)
                        return;

                    app.otherImgList = [];
                    app.otherImgUrl1 = '/img.jpg';
                    app.otherImgUrl2 = '/img.jpg';
                    app.otherImgUrl3 = '/img.jpg';
                },
                otherHandleExceed(files, fileList) {
                    this.$message.warning('只能选择三张图片');
                },
                coverHandleChange(file, fileList) {

                    let isLt10M = file.size / 1024 < this.imgSize;
                    if (!isLt10M) {
                        this.$message.error("图片大小不能超过" + this.imgSize + "KB!");
                        return;
                    }

                    // 限制类型只能为jpg,png
                    let isJPG = file.raw.type === 'image/jpeg';
                    let isPng = file.raw.type === 'image/png';
                    if (!isJPG && !isPng) {
                        this.$message.error("请上传正确格式的图片!");
                        return;
                    }

                    if (fileList.length > 0) {
                        app.coverImgList = [fileList[fileList.length - 1]]//这一步，是 展示最后一次选择文件

                        let URL = window.URL || window.webkitURL;
                        app.coverImgUrl = URL.createObjectURL(app.coverImgList[0].raw);
                    }
                },
                videoHandleChange(file, fileList) {

                    let isLt10M = file.size / 1024 / 1024 < this.videoSize;
                    if (!isLt10M) {
                        this.$message.error("视频大小不能超过 " + this.videoSize + "MB!");
                        return;
                    }

                    // 限制类型
                    let isMp4 = file.raw.type === 'video/mp4';
                    let isAvi = file.raw.type === 'video/avi';
                    let isWebm = file.raw.type === 'video/webm';
                    if (!isMp4 && !isAvi && !isWebm) {
                        this.$message.error('请上传正确格式的视频');
                        return;
                    }

                    let URL = window.URL || window.webkitURL;

                    if (fileList.length > 0) {
                        app.videoList = [fileList[fileList.length - 1]]//这一步，是展示最后一次选择文件
                        app.videoUrl = URL.createObjectURL(app.videoList[0].raw);
                    }
                },
                otherHandleChange(file, fileList) {

                    let isLt10M = file.size / 1024 < this.imgSize;
                    if (!isLt10M) {
                        this.$message.error("图片大小不能超过" + this.imgSize + "KB!");
                        return;
                    }

                    // 限制类型只能为jpg,png
                    let isJPG = file.raw.type === 'image/jpeg';
                    let isPng = file.raw.type === 'image/png';
                    if (!isJPG && !isPng) {
                        this.$message.error("请上传正确格式的图片!");
                        return;
                    }

                    let URL = window.URL || window.webkitURL;
                    app.otherImgList = fileList;
                    for (var i = 0; i < app.otherImgList.length; i++) {
                        if (i === 0) {
                            app.otherImgUrl1 = URL.createObjectURL(app.otherImgList[i].raw);
                        }
                        else if (i === 1) {
                            app.otherImgUrl2 = URL.createObjectURL(app.otherImgList[i].raw);
                        }
                        else if (i === 2) {
                            app.otherImgUrl3 = URL.createObjectURL(app.otherImgList[i].raw);
                        }
                    }
                },
                clearInfo() {
                    this.dataid = -1;
                    this.title = '';
                    this.subTitle = '';
                    ue.setContent('', false);
                    this.isRecommend = 1;
                    this.selectedSpeciesItem = '请选择';

                    app.coverImgList = [];
                    app.videoList = [];
                    app.otherImgList = [];
                    app.coverImgUrl = '/img.jpg';
                    app.videoUrl = '';
                    app.otherImgUrl1 = '/img.jpg';
                    app.otherImgUrl2 = '/img.jpg';
                    app.otherImgUrl3 = '/img.jpg';
                },
                uploadProgress(progressEvent) {
                    /*
                     * progressEvent.loaded :已上传量
                     * progressEvent.total :上传的总大小
                    */
                    const p = Math.floor((progressEvent.loaded / progressEvent.total) * 100);
                    this.percentage = p;
                },
                //提交窗口
                async submitForm() {
                    if (this.selectedSpeciesItem === '请选择') {
                        this.selectedSpeciesItem = '';
                    }

                     //自定义验证
                    if (this.title === '' || this.title === null) {
                        this.$message.warning('标题不能为空');
                        return;
                    }

                    if (this.subTitle === '' || this.subTitle === null) {
                        this.$message.warning('摘要不能为空');
                        return;
                    }

                    let content = ue.getContent();
                    if (content.length === 0) {
                        this.$message.warning('公告内容不能为空');
                        return;
                    }

                    if (content.length > 10000) {
                        this.$message.warning('公告内容过长[文字样式和排版也占用内容长度计算]');
                        return;
                    }

                    if (this.selectedSpeciesItem === '' || this.selectedSpeciesItem === null) {
                        this.$message.warning('分类不能为空');
                        return;
                    }

                    if (this.coverImgList.length === 0) {
                        this.$message.warning('封面图片不能为空');
                        return;
                    }

                            let formData = new FormData();

                            //封面图片
                            for (var i = 0; i < this.coverImgList.length; i++) {
                                formData.append("coverImg" + i, this.coverImgList[i].raw);
                            }

                            //其他图片
                            for (var i = 0; i < this.otherImgList.length; i++) {
                                formData.append("otherImg" + i, this.otherImgList[i].raw);
                            }

                            //视频
                            for (var i = 0; i < this.videoList.length; i++) {
                                formData.append("video" + i, this.videoList[i].raw);
                            }

                            //文字内容
                    var textData = {
                                "dataid": app.dataid, "title": app.title, "subTitle": app.subTitle, "content": content, "selectedSpeciesItem": app.selectedSpeciesItem,
                                 "isRecommend": app.isRecommend,"dataType":app.dataType
                            };
                            formData.append("textData", JSON.stringify(textData));

                            let config = {
                                headers: {
                            'Content-Type': 'multipart/form-data;charset=utf-8',
                                },
                                transformRequest: [function (data) {
                                    return data
                                }],
                                onUploadProgress: this.uploadProgress,
                            }

                            $("#progressDiv").show();
                            this.submitBtnDisabled = true;
                    
                                await axios.post('../../Super/SuperHome/AddOrUpdatePetStory', formData, config).then(res => {
                                if (res.data === "ok") {
                                    this.percentage = 0;
                                     $("#progressDiv").hide();
                            this.submitBtnDisabled = false;
                                    this.$message.success('提交成功');
                                    this.clearInfo();
                                    this.getPetStory(this.currentPageNum, this.searchInput, this.searchSpeciesItem,this.dataType);
                                } else {
                                    this.percentage = 0;
                                    $("#progressDiv").hide();
                            this.submitBtnDisabled = false;
                                    this.$message.warning(res.data);
                                }
                            }, error => {
                                this.percentage = 0;
                                $("#progressDiv").hide();
                        this.submitBtnDisabled = false;
                                alert("错误提示：" + error.message);
                            });
                },
            },
            data() {
                return {
                    submitBtnDisabled: false,
                    percentage:0,
                    videoSize: @Html.Raw(ViewData["videoSize"]),
                    imgSize: @Html.Raw(ViewData["imgSize"]),
                    searchSpeciesItem: '0',
                    currentPageNum: 1,
                    pageSize: @Html.Raw(ViewData["pageSize"]),
                    petInfoCount: 0,
                    searchInput: '',
                    multipleSelection: [],
                    defaultMenuActive: '@Html.Raw(ViewData["defaultMenuActive"])',
                    speciesItems: @Html.Raw(ViewData["speciesList"]),
                    speciesItemsForSearch: @Html.Raw(ViewData["speciesList"]),
                    coverImgList: [],
                    videoList: [],
                    otherImgList: [],
                    coverImgUrl: '/img.jpg',
                    videoUrl: '',
                    otherImgUrl1: '/img.jpg',
                    otherImgUrl2: '/img.jpg',
                    otherImgUrl3: '/img.jpg',
                    dataType: @Html.Raw(ViewData["dataType"]),
                    dataid:-1,
                    title:'',
                    subTitle:'',
                    selectedSpeciesItem: '',
                    isRecommend: 1,
                    tableData: [],
                }
            }
        });
    </script>
}